package models

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Mobile   string `gorm:"type:char(11)" json:"mobile"`
	Password string `gorm:"type:char(32)" json:"password"`
}

func (u *User) FindUserByMobile(db *gorm.DB, mobile string) (*User, error) {
	err := db.Debug().Where("mobile=?", mobile).Find(u).Error
	return u, err
}

func (u *User) CreatedUser(db *gorm.DB) error {
	return db.Debug().Create(u).Error
}

func (u *User) FindUserById(db *gorm.DB, userId int64) (*User, error) {
	err := db.Debug().Where("id=?", userId).Find(u).Error
	return u, err
}
